package ua.yandex.skipass;

import java.util.Date;

/**
 *
 * @author Кирилл
 */
public class SkiPassWorkdayTimeLimitedCard extends SkiPassCard {

    public SkiPassWorkdayTimeLimitedCard(Date activationDate, int id,
            SkiPassTimeShedule timePlan) {
        super(activationDate, timePlan.getTimeFromNow(), id,
                SkiPassType.WORKDAY_TIME_LIMITED);
        if (timePlan.getTimeFromNow().getTime() < activationDate.getTime()) {
            throw new OutOfBoundException(
                    "This card will be activated after it has expired");
        }  
    }
    /*
    public SkiPassWorkdayTimeLimitedCard(int id, SkiPassTimeShedule timePlan) {
        super(new Date(System.currentTimeMillis()), timePlan.getTimeFromNow(),
              id, SkiPassType.WORKDAY_TIME_LIMITED);
        if (timePlan.getTimeFromNow().getTime() < System.currentTimeMillis()) {
            throw new OutOfBoundException(
                    "This card will be activated after it has expired");
        }
    }
    */
    
    @Override
    public boolean passIsAllowed() {
        return !(isBlocked() || SkiPassSystem.isWeekend() || isExpired());
    }
    
}
